package com.ethan.simplesms.untils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Description:
 * @Author ethan
 * @CreateDate: 2022/05/29 下午6:26
 * @UpdateDate: 2022/05/29 下午6:26
 * @Version 1.0
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class R<T> {

    private String msg;
    private T data;
    private int code;

    /**
     * success
     *
     * @param t
     * @param <T>
     * @return
     */
    public static <T> R success(T t) {
           return new R("success",t,1);
    }

    /**
     * error
     *
     * @param code
     * @param msg
     * @return
     */
    public static  R error(int code ,String msg) {
        return new R(msg,null,code);
    }
}
